<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tbody>
		<tr>
			<td colspan="2" nowrap="nowrap">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="school_hdng">
					<tr>
					<td><h3>Bill Details for: <span><?php echo $bill->getOccupant()->getRank().' '.$bill->getOccupant()->getName(); ?></span></h3></td>
					<td align="right"><?php echo link_to(' ', 'Billing/printBill?id='.Utility::EncryptQueryString($bill->getId()), array('class' => 'btn_print', 'target' => '_blank'));
 ?><!--<h3><?php echo $bill->getOccupant()->getUnit()?></h3>--></td>
					</tr>
					
				</table>
			</td>
		</tr>
		<tr>
			<td width="461" nowrap="nowrap" class="heading"></td>
			<td width="464"  align="right"></td>
		</tr>
		<tr>
			<td height="20" colspan="2">&nbsp;</td>
		</tr>
	</tbody>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="datagrid">

</tr>
    <td width="23%"><strong>Station:</strong> <?php echo $bill->getBuilding()->getStation();?></td>
    <td width="28%"><strong>Building No. :</strong> <?php echo $bill->getBuilding()->getBuildingNo() ;?></td>
    <td width="26%"><strong>Consumer No. :</strong> <?php echo $bill->getBuilding()->getConsumerNo();?></td>
    <td width="23%"><strong>Meter No. :</strong> <?php echo $bill->getBuilding()->getMeterNo();?></td>
</tr> 

<tr style="height:30px;">
    <td><strong>Army No. :</strong> <?php echo $bill->getOccupant()->getArmyNo() ;?></td>
    <td><strong>Rank / Name:</strong> <?php echo $bill->getOccupant()->getRank(). ' ' .$bill->getOccupant()->getName();?></td>
    <td><strong>Unit / Formation:</strong> <?php echo $bill->getOccupant()->getUnit();?></td>
    <td><strong>Billing Month: </strong><?php echo $bill->getBillingDate('M-Y');?></td>
</tr>

<tr>
	<td colspan="2" class="last">&nbsp;</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="datagrid">

<tr style="height:50px;">
    <td colspan="4" style="background-color:#F2F2F2"> <h3>Electricity Bill Details</h3> </td>
</tr>

<tr style="height:30px;">
    <td><strong>Previous Reading:</strong> <?php echo $bill->getPreviousReading() ;?></td>
    <td><strong>Present Reading:</strong> <?php echo $bill->getPresentReading();?></td>
    <td><strong>Unit Consumed:</strong> <?php echo $bill->getUnitsConsumed();?></td>
    <td><strong>Free Auth - JCOs/Sldr:</strong> <?php if($bill->getUnitsFree()){ echo $bill->getUnitsFree();} else {echo "Nill";}?></td>
</tr>

<tr style="height:30px;">
    <td><strong>Electricity Billing:</strong> Rs. <?php echo $bill->getUnitsTotal() ;?></td>
    <td><strong>Split AC (Flat Rate):</strong> Rs. <?php echo $bill->getSplitCharges();?></td>
    <td><strong>Window AC (Flat Rate):</strong> Rs. <?php echo $bill->getWindowCharges();?></td>
    <td><strong>Units Billed: </strong><?php echo $billed = $bill->getUnitsConsumed() - $bill->getUnitsFree();?></td>
</tr>

<tr style="height:50px;">
    <td colspan="4" style="background-color:#F2F2F2;"> <h3>Gas &amp; Misc Bill Details</h3> </td>
</tr>

<tr style="height:30px;">
    <td><strong>Gas Charges: Rs. </strong> <?php echo $bill->getGasCharges();?></td>
    <td><strong>Misc Charges: Rs. </strong> <?php echo $bill->getMiscCharges();?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>

<tr style="height:50px;">
    <td colspan="4" style="background-color:#F2F2F2;"> <h3>Water/TV &amp; Other Rent Details</h3> </td>
</tr>

<tr style="height:30px;">
    <td><strong>Water Charges: Rs. </strong> <?php echo $bill->getWaterCharges();?></td>
    <td><strong>TV Charges: Rs. </strong> <?php echo $bill->getTvCharges();?></td>
    <td><strong>Meter Rent: Rs. </strong> <?php echo $bill->getMeterRent() ;?></td>
    <td><strong>Furniture Charges: Rs. </strong> <?php echo $bill->getFurnitureCharges() ;?></td>
</tr>

<tr style="height:30px;">
    <td colspan="3">&nbsp;</td>
    <td style="border:1px solid #000;"> <h3><strong>Grand Total:</strong> <span> Rs. <?php echo $bill->getGrandTotal();?></span></h3> </td>
</tr>

<tr> <td class="last">&nbsp;</td></tr>
</table>

<table width="40%" border="0" cellspacing="0" cellpadding="0" class="datagrid">

<tr style="height:50px;">
    <td colspan="4"> <h3>Previous Bill Details</h3> </td>
</tr>
<tr style="height:30px;">
    <th>Month</th>
    <th>Units</th>
    <th>Total Bill</th>
    <th>Arears</th>
</tr>

<?php if (count($previous_bills)):
foreach ($previous_bills as $m=> $previous_bill):?>

<tr style="height:30px;">
    <td><?php echo $previous_bill->getBillingDate('M/y') ;?></td>
    <td><?php echo $previous_bill->getUnitsConsumed() - $previous_bill->getUnitsFree();?></td>
    <td>Rs. <?php echo $previous_bill->getGrandTotal();?></td>
    <td>Rs. <?php if($previous_bill->getPaymentStatus() == 0){ echo $previous_bill->getGrandTotal();} else {echo "0";}?></td>
</tr>

<?php endforeach; endif; ?>

</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td width="72%" valign="top">
        <table width="93%" border="0" cellspacing="0" cellpadding="0" class="form">
            <tr valign="top">
                <td><h4>Improtant Notes:</h4></td>
            </tr>
            <tr valign="top">
                <td>1. Please mention "meter reading" on occupation/vacation returns.</td>
            </tr>
            <tr>
                <td>2. Please return one copy of recovered bill with full details to 702 PWS for our record.</td>
            </tr>
             <tr>
                <td>3. In case of any query, please contact 702 PWS, Bhimber office at 8213-35749.</td>
            </tr>
        </table>
    </td>

    <td width="28%">
    	    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form">
			<?php if($bill_type == 'officer'):?>
            <tr>
            	<td colspan="3"><h4>Tarrif Details: Officer</h4></td>
            </tr>

				<?php foreach ($tarrifRates as $tarrif):?>
                <tr>
                    <td align="right"><?php echo $tarrif->getTitle() ?> </td>
                    <td> : Rs. </td>
                    <td> <?php echo $tarrif->getOfficerRate();?></td>
                    </tr>
                <?php endforeach;?>
            
            <?php elseif($bill_type == 'commercial'):?>
			<?php
			 	$c = new Criteria;
				$c->add(CalcValuePeer::TITLE, 'commercial_rate');
				$commercial_rate = CalcValuePeer::DoSelectOne($c);
			?>
            <tr>
            	<td colspan="3"><h4>Tarrif Details: Commercial</h4></td>
            </tr>
            <tr>
            	<td align="right">Commercial Rate</td>
                <td> : Rs. </td>
                <td> <?php echo $commercial_rate->getValue();?></td>
                </tr>
            
            <?php else:?>
            <tr>
            	<td colspan="3"><h4>Tarrif Details: JCO/OR/Civil</h4></td>
            </tr>
				<?php foreach ($tarrifRates as $tarrif):?>
                <tr>
                    <td align="right"><?php echo $tarrif->getTitle() ?> </td>
                    <td> : Rs. </td>
                    <td> <?php echo $tarrif->getCivilRate();?></td>
                    </tr>
                <?php endforeach;?>
                <?php endif; ?>
            
            </table>
    </td>
</tr>
</table>
